package com.lft.com.oilgas.controller;

import com.lft.com.oilgas.entity.Business;
import com.lft.com.oilgas.service.IBusinessService;
import com.lft.com.oilgas.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@Transactional
@RequestMapping("/util/business")
public class BusinessController {
    @Autowired
    IBusinessService businessService;
    @ExceptionHandler(Exception.class)
    public Result xx(Exception ex) {
        //noinspection CallToPrintStackTrace
        ex.printStackTrace();
        return new Result(false, "服务器异常，等会再试");
    }
    @RequestMapping("/insterUpdateBusiness")
    public Result InsterOrUpdateAccounts(@RequestBody Business business) {
        return new Result(true, businessService.insterOrUpdateBusiness(business));
    }

    @RequestMapping("/xianqing/{id}")
    public Result xq(@PathVariable("id") Integer id){
        Business business = businessService.selectByid(id);
        return new Result(true,business);
    }
    @RequestMapping("/zenorgai")
    public Result zenggai(@RequestBody Business business){
        businessService.insterOrgei(business);
        return new Result(true,null);
    }
}
